package com.ikangtai.shecare.common.baseView.recordButtonView;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;

import com.ikangtai.shecare.R;

import java.util.Locale;

/**
 * Created by Administrator on 2016/1/20.
 */
public class RecordOptionSymptomButton extends RecordOptionButton implements View.OnClickListener {

    private Context context;
    public static final int RECORD_SYMPTOM_OPTION_WHITE_BACKGROUND_COLOR = 0;
    public static final int RECORD_SYMPTOM_OPTION_BLUE_BACKGROUND_COLOR = 1;
    public static final String RecordOptionSymptomButtonType = "SYMPTOM";

    public RecordOptionSymptomButton(Context context) {
        super(context);
        this.context = context;
    }

    public RecordOptionSymptomButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        backgroundColor = RECORD_SYMPTOM_OPTION_WHITE_BACKGROUND_COLOR;
        setOnClickListener(this);
        setType(RecordOptionSymptomButtonType);
    }

    @Override
    public void onClick(View v) {
        if (backgroundColor == RECORD_SYMPTOM_OPTION_WHITE_BACKGROUND_COLOR) {
            switch (Locale.getDefault().getLanguage()) {
                case "zh":
                    this.setBackground(getResources().getDrawable(R.drawable.record_symptom_button_pressed));
                    this.setTextColor(Color.WHITE);
                    backgroundColor = RECORD_SYMPTOM_OPTION_BLUE_BACKGROUND_COLOR;
                    break;
                default:
                    this.setBackground(getResources().getDrawable(R.drawable.record_symptom_button_pressed_en));
                    this.setTextColor(Color.WHITE);
                    backgroundColor = RECORD_SYMPTOM_OPTION_BLUE_BACKGROUND_COLOR;
            }
        } else {
            switch (Locale.getDefault().getLanguage()) {
                case "zh":
                    this.setBackground(getResources().getDrawable(R.drawable.record_symptom_button_default));
                    this.setTextColor(getResources().getColor(R.color.symptom_color));
                    backgroundColor = RECORD_SYMPTOM_OPTION_WHITE_BACKGROUND_COLOR;
                    break;
                default:
                    this.setBackground(getResources().getDrawable(R.drawable.record_symptom_button_default_en));
                    this.setTextColor(getResources().getColor(R.color.symptom_color));
                    backgroundColor = RECORD_SYMPTOM_OPTION_WHITE_BACKGROUND_COLOR;
            }
        }

    }

    @Override
    public void setBackgroundColor(int backGroundColor) {
        super.setBackgroundColor(backGroundColor);
        if (backGroundColor == RECORD_SYMPTOM_OPTION_WHITE_BACKGROUND_COLOR) {
            switch (Locale.getDefault().getLanguage()) {
                case "zh":
                    this.setBackground(getResources().getDrawable(R.drawable.record_symptom_button_default));
                    this.setTextColor(getResources().getColor(R.color.symptom_color));
                    break;
                default:
                    this.setBackground(getResources().getDrawable(R.drawable.record_symptom_button_default_en));
                    this.setTextColor(getResources().getColor(R.color.symptom_color));
                    break;
            }
        } else {
            switch (Locale.getDefault().getLanguage()) {
                case "zh":
                    this.setBackground(getResources().getDrawable(R.drawable.record_symptom_button_pressed));
                    this.setTextColor(Color.WHITE);
                default:
                    this.setBackground(getResources().getDrawable(R.drawable.record_symptom_button_pressed_en));
                    this.setTextColor(Color.WHITE);
            }
        }
    }


}
